<template>
  <div class="app-container">
    <el-collapse v-model="activeNames">
      <el-collapse-item :title="childData.nickname+'实测&遗传身高曲线'" name="1">
        <InheritHeightCharts :childId="childData.childId" :childData="childData" />
      </el-collapse-item>

      <el-collapse-item :title="childData.nickname+'实测&遗传身高增量对比'" name="2">
        <IncrementalComparisonCharts :childId="childData.childId" :childData="childData" />
      </el-collapse-item>

      <el-collapse-item title="大数据身高对比" name="3">
        <Ranking :childId="childData.childId" :childData="childData" />
      </el-collapse-item>

      <el-collapse-item :title="childData.nickname+'成年身高分布概率'" name="4">
        <NormalHeightCharts :childId="childData.childId" :childData="childData" />
      </el-collapse-item>

      <el-collapse-item title="实测身高" name="5">
        <MeasuredHeightCharts :childId="childData.childId" :childData="childData" />
      </el-collapse-item>

      <el-collapse-item title="遗传身高相比" name="6">
        <ContrastInheritHeight
          :childId="childData.childId"
          :childHeightDetailData="childHeightDetailData"
          :childData="childData"
        />
      </el-collapse-item>
      <el-collapse-item title="近半年增量" name="7">
        <ContrastHalfYeatHeightIncremental
          :childId="childData.childId"
          :childHeightDetailData="childHeightDetailData"
          :childData="childData"
        />
      </el-collapse-item>
      <el-collapse-item title="近一年增量" name="8">
        <ContrastWholeYeatHeightIncrementa
          :childId="childData.childId"
          :childHeightDetailData="childHeightDetailData"
          :childData="childData"
        />
      </el-collapse-item>
      <el-collapse-item title="成年身高预测" name="9">
        <AdultHeight
          :childId="childData.childId"
          :childHeightDetailData="childHeightDetailData"
          :childData="childData"
        />
      </el-collapse-item>
    </el-collapse>
  </div>
</template>

<script>
import { getHeightReportData } from "@/api/child/index";
import echarts from "echarts";
import Ranking from "@/components/MychildReport/ranking";
import InheritHeightCharts from "@/components/MychildReport/inheritHeightCharts";
import NormalHeightCharts from "@/components/MychildReport/normalHeightCharts";
import IncrementalComparisonCharts from "@/components/MychildReport/heightIncrementalComparison";
import MeasuredHeightCharts from "@/components/MychildReport/measuredHeight";
import ContrastInheritHeight from "@/components/MychildReport/contrastInheritHeight";
import ContrastHalfYeatHeightIncremental from "@/components/MychildReport/contrastHalfYeatHeightIncremental";
import ContrastWholeYeatHeightIncrementa from "@/components/MychildReport/contrastWholeYeatHeightIncrementa";
import AdultHeight from "@/components/MychildReport/adultHeight";

export default {
  name: "childReport",
  props: {
    childId: {
      type: Number,
      default: () => {
        return 0;
      }
    },
    childData: {
      type: Object,
      default: () => {
        return {
          ageNum: undefined,
          avatar: undefined,
          birthday: undefined,
          childId: undefined,
          childType: 1,
          familyCode: undefined,
          height: 0,
          heightDad: 0,
          heightInherit: 0,
          heightMum: 0,
          nickname: undefined,
          sex: 1,
          weight: 0
        };
      }
    }
  },
  components: {
    InheritHeightCharts,
    NormalHeightCharts,
    IncrementalComparisonCharts,
    Ranking,
    MeasuredHeightCharts,
    ContrastInheritHeight,
    ContrastHalfYeatHeightIncremental,
    ContrastWholeYeatHeightIncrementa,
    AdultHeight
  },
  data() {
    return {
      loading: false,
      activeNames: ["1", "2", "3", "4", "5", "6", "7", "8", "9"],
      //孩子身高详情，如当前身高，当前遗传身高，成年身高预测，遗传增量，实测增量等
      childHeightDetailData: {
        inheritHeight: 0,
        inheritHeightStatus: "",
        measuredHeight: {
          value: 0,
          halfYearIncremental: 0,
          halfYearIncrementalStatus: "",
          wholeYearIncremental: 0,
          wholeYearIncrementalStatus: "",
          recordedAt: ""
        },
        currentInheritHeight: {
          value: 0,
          halfYearIncremental: 0,
          wholeYearIncremental: 0,
          recordedAt: "06-19"
        }
      }
    };
  },

  mounted() {
    this.getHeightDetailData();
  },
  watch: {
    //监听子控件内容的改动,发送给父级组件
    childId: {
      handler(newValue, oldValue) {
        this.getHeightDetailData();
      },
      deep: true
    }
  },
  methods: {
    getHeightDetailData() {
      this.loading = true;
      let series_data = [];
      let xAxisData = [];
      getHeightReportData(this.childId).then(response => {
        this.childHeightDetailData = response.data;
        // console.log(this.childHeightDetailData);
      });
    }
  }
};
</script>